//
//  KMusicTableViewCell.m
//  K歌之王
//
//  Created by 小晓 on 16/1/2.
//  Copyright © 2016年 xiao. All rights reserved.
//

#import "KMusicTableViewCell.h"
#import "KSingingRecordViewCtr.h"

@implementation KMusicTableViewCell

- ( instancetype ) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;

        _headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(15, 5, 60, 60)];
        [self.contentView addSubview:_headImageView];
        
        _musicLabel = [[UILabel alloc]initWithFrame:CGRectMake(30+_headImageView.frame.size.width, 5,[UIScreen mainScreen].bounds.size.width-30-_headImageView.frame.size.width-50 , 20)];
        [self.contentView addSubview:_musicLabel];
        
        _singerLabel = [[UILabel alloc]initWithFrame:CGRectMake(30+_headImageView.frame.size.width, 25, [UIScreen mainScreen].bounds.size.width-30-_headImageView.frame.size.width-50 , 20)];
        _singerLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_singerLabel];
        
        _sizeLabel = [[UILabel alloc]initWithFrame:CGRectMake(30+_headImageView.frame.size.width, 45, [UIScreen mainScreen].bounds.size.width-30-_headImageView.frame.size.width-50 , 20)];
        _sizeLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_sizeLabel];
        
        UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-50, (71-40)*0.5, 40, 40)];
        [btn setBackgroundImage:[UIImage imageNamed:@"music.png"] forState:(UIControlStateNormal)];
        [btn addTarget:self action:@selector(KmusicView:) forControlEvents:(UIControlEventTouchUpInside)];
        [self.contentView addSubview:btn];
        UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 70, [UIScreen mainScreen].bounds.size.width, 1)];
        lineView.backgroundColor = [UIColor groupTableViewBackgroundColor];
        [self.contentView addSubview:lineView];
    }
    return self;
}

- (void)updataCellViewWithHeadData:(HotMusicMsgDataModel *)musicModel superViewCtr:(UIViewController *)superViewStr{
    [_headImageView sd_setImageWithURL:[NSURL URLWithString:musicModel.avatar] placeholderImage:[UIImage imageNamed:@"图层-27@2x.png"]];
    _musicLabel.text = musicModel.name;
    _singerLabel.text = musicModel.singerName;
    _sizeLabel.text = [NSString stringWithFormat:@"%@M",musicModel.size];
    _currentViewCtr = superViewStr;
    _musicUrl = musicModel.accompanyUrl;
    _lyrUrl = musicModel.lyric;
    
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(void)KmusicView:(UIButton *)seader{
    KSingingRecordViewCtr * kSingViewCtr = [KSingingRecordViewCtr new];
    kSingViewCtr.musicUrl = _musicUrl;
    kSingViewCtr.lyrUrl = _lyrUrl;
    kSingViewCtr.singerName = _singerLabel.text;
    kSingViewCtr.musicName = _musicLabel.text;
    [_currentViewCtr.navigationController pushViewController:kSingViewCtr animated:YES];
}

@end
